<?php

namespace App\Models\CarModels;

use App\Models\SystemManagement\Employee;
use Illuminate\Database\Eloquent\Model;

class CarMaintence extends Model
{
    //
    protected $table = 'car_maintenance_records';
    protected $fillable = ['project','department','current_mileage','previous_mileage','bill','next_mileage',
        'maintenance_date','next_maintenance_date','previous_maintenance_date','desc','car_id','staff_id','next_project'];
    public function car(){
        return $this->belongsTo(CarInfo::class,'car_id','id')->with('department')->with('area')->with('kind');
    }

    public function staff()
    {
        return $this->belongsTo(Employee::class,'staff_id')->with(['department','post']);
    }

    public function images()
    {
        return $this->hasMany(CarMaintenceFile::class,'record_id')->with('files');
    }
}
